import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class SmallTools {

	public static void main(String[] args) {

//		// 第一步加载驱动
//		try {
//			Class.forName("com.mysql.jdbc.Driver");
//		} catch (ClassNotFoundException e) {
//			System.out.println("加载驱动失败。。。。。。");
//			e.printStackTrace();
//		}
//
//
//		Connection coon = null;
//		try {
//			coon = DriverManager.getConnection("jdbc:mysql://rm-wz90qibh708efw9c6co.mysql.rds.aliyuncs.com:3306/iiiup", "root", "UP626enj!");
//		} catch (SQLException e) {
//			// TODO Auto-generated catch block
//			System.out.println("连接数据库失败。。。。。。。");
//			e.printStackTrace();
//		}
//		
//		PreparedStatement prep = null; 
//		Statement stmt = null;
//		ResultSet rs =null;
//		String sql1 = "select product_id,product_name from up_product";
//	
//	    try {
//	    	stmt = coon.createStatement();
//			rs = stmt.executeQuery(sql1);
//			
//		    while(rs.next()){
//		    	  int product_id = rs.getInt("product_id");
//		    	  String product_name = rs.getString("product_name");
//		    	  System.out.println("product_id:"+product_id);
//		    	  System.out.println("product_name:"+product_name);
//				  String upsql = "update up_product set product_name_sort =? where product_id =?" ;	
//				  prep = coon.prepareStatement(upsql);
//				  prep.setString(1, StringFilter(product_name));
//				  prep.setInt(2, product_id);
//				  prep.executeUpdate();  
//		    }
//		    prep.close();
//		    rs.close();
//	        stmt.close();
//			coon.close();
//		} catch (SQLException e) {
//			// TODO Auto-generated catch block
//			e.printStackTrace();
//		}


 
		String str = "现货。金慈英同款  俏皮木耳边 娃娃领 配色印花 蝴蝶结系带，衬衫";
		System.out.println(str); 
		StringFilter(str);
	 
	}
	
	 public static String  StringFilter(String str) { 
	// 只允许字母和数字 // String regEx ="[^a-zA-Z0-9]"; 
	// 清除掉所有特殊字符 
//	String regEx="[`~!@#$%^&*()+=|{}':;',\\[\\].<>/?~！@#￥%……&*（）——+|{}【】‘；：”“’。，、？]"; 
	String regEx1="[实][拍]"; 
	String regEx2="[实][价]"; 
	String regEx3="[\\s！~～;。：，]"; 
	String regEx4="2017"; 
	String regEx5="[以][检][测]"; 
	String regEx6="[质][检]"; 
	String regEx7="[现][货]";

	Pattern p1 = Pattern.compile(regEx1); 
	Matcher m1 = p1.matcher(str);
	Pattern p2 = Pattern.compile(regEx2); 
	Matcher m2 = p2.matcher(m1.replaceAll("").trim());
	Pattern p3 = Pattern.compile(regEx3); 
	Matcher m3 = p3.matcher(m2.replaceAll("").trim());
	Pattern p4 = Pattern.compile(regEx4); 
	Matcher m4 = p4.matcher(m3.replaceAll("").trim());
	Pattern p5 = Pattern.compile(regEx5); 
	Matcher m5 = p5.matcher(m4.replaceAll("2018").trim());
	
	Pattern p6 = Pattern.compile(regEx6); 
	Matcher m6 = p6.matcher(m5.replaceAll("").trim());
	
	Pattern p7 = Pattern.compile(regEx7); 
	Matcher m7 = p7.matcher(m6.replaceAll("").trim());
	
	System.out.println(m7.replaceAll("").trim());
	return m7.replaceAll("").trim();

	} 

}
